<?
	include_once('global.php');
	if(isset($_GET['refer']))
	{
		$refer = $_SESSION['refer'] = $_GET['refer'];
	}elseif(isset($_SESSION['refer']))
	{
		$refer = $_SESSION['refer'];
	}else{
		$refer = $_SESSION['refer'] = $_SERVER['HTTP_REFERER'];
	}
	if($refer == null || $refer == '') $refer = '../main.php';
	
	if(isset($_REQUEST['Email']))
	{
		if($ValidationErrors = Login($_REQUEST['Email'], $_REQUEST['Password']))
		{
			$rs = $_REQUEST;
		}else{
			echo "refer: $refer";
			header("location: $refer");
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Please Login</title>
        <link rel="stylesheet" type="text/css" href="forms.css"/>
        <style type="text/css">
			label{
				color:blue;
			}
			form{
				display:block;
			    text-align:center;
				padding-top:200px;
			}
			div.background
			{
				background-color:#E8E8E8; 
				padding-bottom:10px; padding-top:10px; 
				margin-right:30%; margin-left:30%;
			}
		</style>
    </head>
    
    <body background="../Admin/Images/saturnvalley.jpg" bgproperties="fixed">
    	<ul class="error">
            <? foreach($ValidationErrors as $key => $value) { ?>
                <li><?=$key?>: <?=$value?> </li>
            <? } ?>
        </ul>
        <form method="post" >
        	<div class="background">
                <div>
                    <div style="font-size:18px">
                        Welcome to Saturn Valley Gaming, Please Sign In.
                    </div>
                    <div>
                        <span style="padding-left:28px">Email:</span><label for="Email"></label>
                        <input
                            class="<?=isset($ValidationErrors['Email']) ? 'iError' : ''?>"
                            type="text" name="Email"
                            value="<?=$rs['Email']?>" id="Email" />
                        <? if(isset($ValidationErrors['Email'])) { ?><?=$ValidationErrors['Email']?><? } ?>
                    </div>
                    <div>
                        Password:<label for="Password"></label>
                        <input
                            class="<?=isset($ValidationErrors['Password']) ? 'iError' : ''?>"
                            type="password" name="Password"
                            value="<?=$rs['Password']?>" id="Password" />
                        <? if(isset($ValidationErrors['Password'])) { ?><?=$ValidationErrors['Password']?><? } ?>
                    </div>
                    <input type="submit" value="Login" />
                    <a href="">Forgot Email</a>
                    <a href="">Forgot Password</a>
                </div>
                <div>
                    <a href="../main.php">Home Page</a>
                </div>
            </div>
        </form>
        
    </body>
</html>